<template>
  <van-tabbar v-model="active" @change="onChange">
    <van-tabbar-item name="home" icon="home-o">首页</van-tabbar-item>
    <van-tabbar-item name="category" icon="todo-list-o">分类</van-tabbar-item>
    <van-tabbar-item name="cart" icon="shopping-cart-o"
      >购物车</van-tabbar-item
    >
    <van-tabbar-item name="user" icon="friends-o">个人</van-tabbar-item>
  </van-tabbar>
</template>

<script>
import { ref } from "vue";
import { useRouter } from "vue-router";
export default {
  setup() {
    const active = ref("home");
    const router = useRouter();
    const onChange = (name) => {
      router.push({ path: `/${name}` });
    };
    return { active, onChange };
  },
};
</script>

<style></style>
